package com.dsa.recursive;

public class Sum {

    private Sum() {}

    public static int summary(int[] data) {
        return summary(data, 0, data.length - 1);
    }

    public static int summary(int[] data, int l, int r) {
        if (l > r) {
            return 0;
        }
        return data[l] + summary(data, l + 1, r);
    }

    public static void main(String[] args) {
        int value = summary(new int[]{1, 2, 3, 4, 5}, 1, 2);
        System.out.println("value = " + value);
    }
}
